use data, clear
set more off
set scheme s1color



*generate interactions
gen t3above=t3*above

foreach vv in t3 above t3above  {
	gen `vv'_exp=expellee*`vv'
}


local cc=0
local outcomes donate_st logamount pc_att rec_suffer rec_abroad 
local controls i.sex i.state i.F4 i.F13 i.age10 


foreach var in `outcomes'  {
foreach num of numlist 90 95 {
	reg `var' `controls'  above t3 t3above if treatment>1&expellee==0, robust
estimates store oldest
lincomest t3, level(`num')
parmest,label saving(`var'`num'belownoexp.dta,replace)  level(`num')
estimates restore oldest

estimates store oldest
lincomest t3+t3above, level(`num')
parmest,label saving(`var'`num'abovenoexp.dta,replace)  level(`num')
estimates restore oldest

	reg `var'  `controls' above t3 t3above if treatment>1&expellee==1, robust
estimates store oldest
lincomest t3, level(`num')
parmest,label saving(`var'`num'belowexp.dta,replace)  level(`num')
estimates restore oldest
	
	estimates store oldest
lincomest t3+t3above, level(`num')
parmest,label saving(`var'`num'aboveexp.dta,replace)  level(`num')
estimates restore oldest

reg `var'  `controls' t3_exp above_exp t3above_exp expellee above t3 t3above  if treatment>1, robust
estimates store oldest
lincomest t3_exp, level(`num')
parmest,label saving(`var'`num'belowdif.dta,replace)  level(`num')
estimates restore oldest

estimates store oldest
lincomest t3_exp+t3above_exp, level(`num')
parmest,label saving(`var'`num'abovedif.dta,replace)  level(`num')
estimates restore oldest
local cc=`cc'+1
}
}


use donate_st90abovedif,clear

foreach x of local outcomes  {
foreach num of numlist 90 {
append using `x'`num'belownoexp
append using `x'`num'belowexp
append using `x'`num'abovenoexp
append using `x'`num'aboveexp
append using `x'`num'belowdif
append using `x'`num'abovedif
}
}
gen id=_n-1
drop if id==0
sort id
save all.results90.dta, replace 

use donate_st95abovedif,clear

foreach x of local outcomes  {
foreach num of numlist 95 {
append using `x'`num'belownoexp
append using `x'`num'belowexp
append using `x'`num'abovenoexp
append using `x'`num'aboveexp
append using `x'`num'belowdif
append using `x'`num'abovedif
}
}
gen id=_n-1
drop if id==0
sort id
save all.results95.dta, replace 

use all.results95.dta
merge 1:1 id using all.results90.dta, keepusing(min90 max90)


recode id (1/6=3) (7/12=2) (13/18=1) (19/24=4) (25/30=5),into(outcomes)
recode id (2 4 =2) (8 10=2) (14 16=2) (20 22=2) (26 28=2)/*
*/ (1 3 =1) (7 9=1) (13 15=1) (19 21=1) (25 27=1)/*
*/ (5 6=3) (11 12=3) (17 18=3) (23 24=3) (29 30=3),into(groups)
recode id (1 2 5 7 8 11 13 14 17 19 20 23 25 26 29=1) (3 4 6 9 10 12 15 16 18 21 22 24 27 28 30=2),into(above)

save allresults.dta, replace

foreach x of local outcomes  {
foreach num of numlist 90 95 {

rm `x'`num'belownoexp.dta
rm `x'`num'belowexp.dta
rm `x'`num'abovenoexp.dta
rm `x'`num'aboveexp.dta
rm `x'`num'belowdif.dta
rm `x'`num'abovedif.dta
}
}
foreach num of numlist 90 95 {
rm all.results`num'.dta
}











